package br.ifrn.tads.poo.biblioteca.jdbc;

import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
 
import java.sql.Connection;
import java.sql.Statement;
 
public class AcessoBanco {
    public static void main(String[] args) {
    	
        Connection conn;
        PreparedStatement preparedStatement;
        Statement stm;
        
        try {
            Class.forName("com.mysql.jdbc.Driver").newInstance(); 
           
            conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/biblioteca?user=andre&password=123456");
           
            stm = conn.createStatement();
            
            
            ResultSet rs = stm.executeQuery("SELECT * FROM Administrador"); 
            while(rs.next())  
            {  
 
                String nome = rs.getString("nome");  
 
                System.out.println(" NOME: "+ nome);  
            }
 
                        /**********************************************************************
                        ***********COMANDOS SELECT - INSERT - UPDATE - DELETE******************
                        **********************************************************************/
 
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (ClassNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (InstantiationException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
 
    }
}